﻿using MHI.DeviceManager.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WebFoundation.Data;

namespace MHI.DeviceManager.Data
{
    internal class DevDeviceTQueryDAO : QueriableDAO<DevDeviceT>
    {
        protected static DbManager _dbManager = WebFoundation.Data.DbManager.FromConfig("DefaultConnection");

        public DevDeviceTQueryDAO()
        : base(_dbManager)
        {
        }

        public DevDeviceTQueryDAO(DbManager db)
            : base(db)
        {
        }

        /// <summary>
		/// 获取所有DevDeviceT,table items:dev_device_t信息 
		/// </summary>
		/// <returns></returns>
		public IEnumerable<DevDeviceT> GetDevDeviceTAllItems()
        {
            var query = this.CreateQuery();
            query.Filter().Eq(r => r.IsUse, 1);
            return this.Query(query);
        }

        /// <summary>
        /// 获取某个位置的所有设备
        /// </summary>
        /// <param name="locationId"></param>
        /// <returns></returns>
        public IEnumerable<DevDeviceT> GetDevicesByLocation(int locationId)
        {
            var query = this.CreateQuery();
            query.Filter().Eq(r => r.Location, locationId);
            return this.Query(query);
        }
    }
}
